package cn.kgc.util;
/**
 * 分页工具类
 * @author Fling
 *
 */
public class Page {
	//页大小
	private Integer pageSize=3;
	//总记录数
	private Integer count;
	//总页数
	private Integer totalPage;
	//当前页
	private Integer pageNum;

	public Page() {
	}

	public Page(Integer pageSize, Integer count, Integer totalPage, Integer pageNum) {
		this.pageSize = pageSize;
		this.count = count;
		this.totalPage = totalPage;
		this.pageNum = pageNum;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public Integer getCount() {
		return count;
	}

	public void setCount(Integer count) {
		this.count = count;
	}

	public Integer getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(Integer count) {
		//如果总记录数除余页大小	能整除则总页数为结果	否则结果+1
		this.totalPage = count%pageSize==0?count/pageSize:count/pageSize+1;
	}

	public Integer getPageNum() {
		return pageNum;
	}

	public void setPageNum(Integer pageNum) {
		if(pageNum<1 || totalPage==0){
			this.pageNum=1;
		}else if (pageNum>totalPage){
			this.pageNum=totalPage;
		}else{
			this.pageNum = pageNum;
		}

	}
}
